/**
 * Created by wen.gao on 2017/5/7.
 */
var Sequelize = require('sequelize');

var sequelize = new Sequelize('authcenter', 'root', 'root', {
    host: 'localhost',
    dialect: "mysql",
    pool: {
        max: 20,
        min: 5,
        idle: 10000
    }
});

// model
var User = sequelize.define('user', {
    userId: {
        primaryKey: true,
        type: Sequelize.INTEGER,
        field: 'userId' // Will result in an attribute that is firstName when user facing but first_name in the database
    },
    userName: {
        type: Sequelize.STRING
    },
    userPassword: {
        type: Sequelize.STRING
    },
    userEmail: {
        type: Sequelize.STRING
    },
    userPhone: {
        type: Sequelize.STRING
    },
    userPortrait: {
        type: Sequelize.STRING
    },
    userGender: {
        type: Sequelize.INTEGER
    },
    userCreateTime: {
        type: Sequelize.DATE
    },
    userStatus: {
        type: Sequelize.INTEGER
    }
}, {
    freezeTableName: true, // Model tableName will be the same as the model name
    timestamps : false // Adds createdAt and updatedAt timestamps to the model.
});

User.sync({force: false}).then(function () {
    // Table created
    return User.create({
        userName: "gaowen",
        userPassword: "123123",
        userGender: 1
        // userEmail : "wen.gao@prnasia.com",
        // userPhone : "15011448840"
    });
});